/* * * created By Xu Peng * */
<template>
  <el-date-picker
    size="small"
    v-model="data"
    :type="timeType"
    align="right"
    unlink-panels
    :style="{ width: mini ? '220px' : 'auto' }"
    @change="handleChange"
    :value-format="valueFormat"
    :format="format"
    range-separator="至"
    :start-placeholder="startPlaceholder"
    :end-placeholder="endPlaceholder"
    :default-time="defaultTime"
  />
</template>

<script>
export default {
  props: {
    timeType: {
      type: String,
      default: "daterange"
    },
    mini: {
      type: Boolean,
      default: false
    },
    value: {
      type: [String, Array]
    },
    valueFormat: {
      type: String,
      default: "yyyy-MM-dd"
    },
    format: {
      type: String,
      default: "yyyy-MM-dd"
    },
    startPlaceholder: {
      type: String,
      default: "开始日期"
    },
    endPlaceholder: {
      type: String,
      default: "结束日期"
    },
    defaultTime: {
      type: Array,
      default: () => ["00:00:00", "00:00:00"]
    }
  },
  data() {
    return {
      data: this.value
    }
  },
  watch: {
    value(val) {
      this.data = val
    }
  },
  created() {
    console.log(this.mini)
  },
  methods: {
    handleChange(val) {
      if (!val) {
        return this.$emit("input", ["", ""])
      }
      this.$emit("input", val)
    }
  }
}
</script>
<style lang="less"></style>
